function bookEdit(id) {
    location.href = `/books/${id}`
}

function bookAdd() {
    location.href = '/add'
}

function bookDelete(id) {
    if (confirm('确定要删除吗？')) {
        const currentParams = new URLSearchParams(location.search)
        axios.delete(`books/${id}`).then(res => {
            if (res.status === 200) {
                const queryString = currentParams.toString()

                location.href = `/books${queryString ? `?${queryString}` : ''}`
            }
        })
    }
}

function bookSelect() {
    let keyword = document.querySelector('input[name=keyword]').value
    location.href = `/books?keyword=${keyword}`
}